<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Reponse extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idreponse;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Labelrepense;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Repensevrai;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Descriptionhelp;

    /**
     * Database var type varchar(255)
     *
     * @var string
     */
    protected $_TypereponseIdtypereponse;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_QuestionIdQuestion;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Score;


    /**
     * Parent relation fk_reponse_typereponse1
     *
     * @var Application_Model_Typereponse
     */
    protected $_Typereponse;

    /**
     * Parent relation fk_reponse_Question1
     *
     * @var Application_Model_Question
     */
    protected $_Question;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idreponse'=>'Idreponse',
            'labelrepense'=>'Labelrepense',
            'repensevrai'=>'Repensevrai',
            'descriptionhelp'=>'Descriptionhelp',
            'typereponse_idtypereponse'=>'TypereponseIdtypereponse',
            'Question_idQuestion'=>'QuestionIdQuestion',
            'score'=>'Score',
        ));

        $this->setParentList(array(
            'FkReponseTypereponse1'=> array(
                    'property' => 'Typereponse',
                    'table_name' => 'Typereponse',
                ),
            'FkReponseQuestion1'=> array(
                    'property' => 'Question',
                    'table_name' => 'Question',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column idreponse
     *
     * @param int $data
     * @return Application_Model_Reponse
     */
    public function setIdreponse($data)
    {
        $this->_Idreponse = $data;
        return $this;
    }

    /**
     * Gets column idreponse
     *
     * @return int
     */
    public function getIdreponse()
    {
        return $this->_Idreponse;
    }

    /**
     * Sets column labelrepense
     *
     * @param text $data
     * @return Application_Model_Reponse
     */
    public function setLabelrepense($data)
    {
        $this->_Labelrepense = $data;
        return $this;
    }

    /**
     * Gets column labelrepense
     *
     * @return text
     */
    public function getLabelrepense()
    {
        return $this->_Labelrepense;
    }

    /**
     * Sets column repensevrai
     *
     * @param string $data
     * @return Application_Model_Reponse
     */
    public function setRepensevrai($data)
    {
        $this->_Repensevrai = $data;
        return $this;
    }

    /**
     * Gets column repensevrai
     *
     * @return string
     */
    public function getRepensevrai()
    {
        return $this->_Repensevrai;
    }

    /**
     * Sets column descriptionhelp
     *
     * @param text $data
     * @return Application_Model_Reponse
     */
    public function setDescriptionhelp($data)
    {
        $this->_Descriptionhelp = $data;
        return $this;
    }

    /**
     * Gets column descriptionhelp
     *
     * @return text
     */
    public function getDescriptionhelp()
    {
        return $this->_Descriptionhelp;
    }

    /**
     * Sets column typereponse_idtypereponse
     *
     * @param string $data
     * @return Application_Model_Reponse
     */
    public function setTypereponseIdtypereponse($data)
    {
        $this->_TypereponseIdtypereponse = $data;
        return $this;
    }

    /**
     * Gets column typereponse_idtypereponse
     *
     * @return string
     */
    public function getTypereponseIdtypereponse()
    {
        return $this->_TypereponseIdtypereponse;
    }

    /**
     * Sets column Question_idQuestion
     *
     * @param int $data
     * @return Application_Model_Reponse
     */
    public function setQuestionIdQuestion($data)
    {
        $this->_QuestionIdQuestion = $data;
        return $this;
    }

    /**
     * Gets column Question_idQuestion
     *
     * @return int
     */
    public function getQuestionIdQuestion()
    {
        return $this->_QuestionIdQuestion;
    }

    /**
     * Sets column score
     *
     * @param int $data
     * @return Application_Model_Reponse
     */
    public function setScore($data)
    {
        $this->_Score = $data;
        return $this;
    }

    /**
     * Gets column score
     *
     * @return int
     */
    public function getScore()
    {
        return $this->_Score;
    }

    /**
     * Sets parent relation TypereponseIdtypereponse
     *
     * @param Application_Model_Typereponse $data
     * @return Application_Model_Reponse
     */
    public function setTypereponse(Application_Model_Typereponse $data)
    {
        $this->_Typereponse = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idtypereponse'];
        }

        $this->setTypereponseIdtypereponse($primary_key);

        return $this;
    }

    /**
     * Gets parent TypereponseIdtypereponse
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Typereponse
     */
    public function getTypereponse($load = true)
    {
        if ($this->_Typereponse === null && $load) {
            $this->getMapper()->loadRelated('FkReponseTypereponse1', $this);
        }

        return $this->_Typereponse;
    }

    /**
     * Sets parent relation QuestionIdQuestion
     *
     * @param Application_Model_Question $data
     * @return Application_Model_Reponse
     */
    public function setQuestion(Application_Model_Question $data)
    {
        $this->_Question = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idQuestion'];
        }

        $this->setQuestionIdQuestion($primary_key);

        return $this;
    }

    /**
     * Gets parent QuestionIdQuestion
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Question
     */
    public function getQuestion($load = true)
    {
        if ($this->_Question === null && $load) {
            $this->getMapper()->loadRelated('FkReponseQuestion1', $this);
        }

        return $this->_Question;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Reponse
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Reponse());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Reponse::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdreponse() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idreponse = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdreponse()));
    }
}
